package com.xunshi.hikangvision.Controller;

import com.xunshi.hikangvision.untils.PreverViewUntil;
import com.xunshi.hikangvision.vo.LoginVo;
import com.xunshi.hikangvision.vo.result.R;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/playvision")
public class HKController {
//    @Resource PreverViewUntil preverViewUntil;
    /**
     * 登录并开启预览
     * @param loginVo
     * @return
     */
    @PostMapping("/loginAndPlayView")
    public R<LoginVo> loginAndPlayView(@RequestBody LoginVo loginVo)
    {
       return R.buildOkData(PreverViewUntil.loginAndPlayView(loginVo));
    }

    /**
     * 退出预览&登录
     */
    //@ApiParam("loginAndPlayView接口中返回的lUserID")
    //@ApiParam("loginAndPlayView接口中返回的lPlayID")
    @GetMapping("/logoutPlayView")
    public R logoutPlayView(
            @RequestParam (value = "lUserID",required = true) String lUserID,
            @RequestParam (value = "lPlayID",required = false) String lPlayID)
    {
        if(null!=lPlayID)
        {
            PreverViewUntil.logoutPlayView(lUserID,lPlayID);
        }
        else
        {
            PreverViewUntil.logoutPlayView(lUserID);
        }
        return R.buildOk();
    }
    /**
     * 登录（判断是否在线），只登录不预览
     * ---支持批量登录
     * @param loginVos
     * @return
     */
    @PostMapping("/login")
    public R<List<LoginVo>> login(@RequestBody List<LoginVo> loginVos)
    {
        return R.buildOkData(PreverViewUntil.login(loginVos));
    }
    /**
     * 预览某个摄像头
     * @param loginVo
     * @return
     */
    @PostMapping("/playView")
    public R<LoginVo> playView(@RequestBody LoginVo loginVo)
    {
        return R.buildOkData(PreverViewUntil.playView(loginVo));
    }

    /**
     * 只关闭某个摄像头预览，但不退出登录
     * @param loginVo
     * @return
     */
    @PostMapping("/logoutPlayViewOnly")
    public R<LoginVo> logoutPlayViewOnly(@RequestBody LoginVo loginVo)
    {
        return R.buildOkData(PreverViewUntil.logoutPlayViewOnly(loginVo));
    }


}
